# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgbase=dav1d
pkgname=(dav1d dav1d-doc)
pkgver=1.2.0
pkgrel=1
pkgdesc='AV1 cross-platform decoder focused on speed and correctness'
url='https://code.videolan.org/videolan/dav1d/'
arch=('x86_64')
license=('BSD')
makedepends=('meson' 'ninja' 'nasm' 'doxygen' 'graphviz' 'xxhash')
source=(https://downloads.videolan.org/pub/videolan/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
        https://code.videolan.org/videolan/dav1d-test-data/-/archive/${pkgver}/dav1d-test-data-${pkgver}.tar.gz)
sha512sums=('1f1775bdcdbc38a0bb12d7f14f01ee321cc03f15d8b7c6fabe2ada3a3c46885b0eff5851ea912079a1519ef01278c3a192e3b0347b0ab9b25cafab4124f1ae6a'
            'SKIP'
            'f91d724989b2671911dae8f46a39c2b25b89356923b255bbd249f9a4529daaadc176098928d91e930989d647515f4f403dfe23bbfcd5adc1fa86b32d195bc0fa')
b2sums=('f9c9ca8c48ba2cae8e2137bb46e9db9a2070b3fba35ca142fde836f20be8a0db11b3b0dc3f78d06780d5cf6d014b0a6b545368371f421864d3f30a35ca6fe5ef'
        'SKIP'
        '89ba3eb72b566ee12cff65db12f76d8cd23debb883a3f25d054799c18752a9b679656818fcb7ab3b5405259afaec28d0b49b42ec732004e85d42cabaa07bd103')
validpgpkeys=('65F7C6B4206BD057A7EB73787180713BE58D1ADC') # VideoLAN Release Signing Key

prepare() {
  cd ${pkgbase}-${pkgver}
  ln -s "${srcdir}/dav1d-test-data-${pkgver}" tests/dav1d-test-data
}

build() {
  cd ${pkgbase}-${pkgver}
  arch-meson \
    -Dtestdata_tests=true \
    -Denable_docs=true \
    build
  ninja -C build all doc/html
}

check() {
  cd ${pkgbase}-${pkgver}/build
  meson test
}

package_dav1d() {
  depends=('glibc')
  provides=('libdav1d.so')
  optdepends=('dav1d-doc: HTML documentation')

  cd ${pkgbase}-${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -Dm 644 README.md CONTRIBUTING.md NEWS -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

package_dav1d-doc() {
  pkgdesc+=" (documentation)"

  cd ${pkgbase}-${pkgver}
  install -d "${pkgdir}/usr/share/doc/${pkgbase}"
  cp -r build/doc/html -t "${pkgdir}/usr/share/doc/${pkgbase}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
